package com.tanhua.app.controller;

import com.tanhua.app.service.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/baidu")
public class BaiduController {

    @Autowired
    private BaiduService baiduService;

    /**
     * 上报地理位置
     * @param param
     * @return
     */
    @PostMapping("/location")
    public ResponseEntity updateLocation(@RequestBody Map param){
        //1.获取地理位置参数（经纬度，地理位置内容）
        Double longitude = Double.valueOf(param.get("longitude").toString());
        Double latitude = Double.valueOf(param.get("latitude").toString());
        String addrStr = param.get("addrStr").toString();

        //2.调用Service层执行业务逻辑
        baiduService.updateLocation(longitude,latitude,addrStr);

        //3.返回结果
        return ResponseEntity.ok(null);
    }
}
